<?php

/**
 * rmUser form base class.
 *
 * @method rmUser getObject() Returns the current form's model object
 *
 * @package    ressourceManager
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BasermUserForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id_user'       => new sfWidgetFormInputHidden(),
      'login'         => new sfWidgetFormInputText(),
      'password'      => new sfWidgetFormInputText(),
      'name'          => new sfWidgetFormInputText(),
      'surname'       => new sfWidgetFormInputText(),
      'email'         => new sfWidgetFormInputText(),
      'is_active'     => new sfWidgetFormInputCheckbox(),
      'creation_date' => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id_user'       => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id_user')), 'empty_value' => $this->getObject()->get('id_user'), 'required' => false)),
      'login'         => new sfValidatorString(array('max_length' => 100, 'required' => false)),
      'password'      => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'name'          => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'surname'       => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'email'         => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'is_active'     => new sfValidatorBoolean(array('required' => false)),
      'creation_date' => new sfValidatorDateTime(),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorDoctrineUnique(array('model' => 'rmUser', 'column' => array('id_user')))
    );

    $this->widgetSchema->setNameFormat('rm_user[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'rmUser';
  }

}
